﻿using MyBlog.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyBlog
{
    public partial class NewPost : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //this.TextBoxAuthor.Text = Membership.GetUser().UserName;
        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void ButtonSubmitPost_Click(object sender, EventArgs e)
        {
            MyBlogDBEntities blogDB = new MyBlogDBEntities();
            Post newPost = new Post();
            newPost.Title = this.TextBoxTitle.Text;
           // newPost.AuthorUserId =(Guid?) Membership.GetUser().ProviderUserKey;
            newPost.PostDate = DateTime.Now;
            newPost.PostContent = this.TextBoxMessage.Text;
            blogDB.Posts.Add(newPost);
            blogDB.SaveChanges();
            Response.Redirect("~/Default.aspx");
        }
    }
}